package com.CST.websocket;

import com.CST.common.api.ResultObject;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author qtx
 * @since 2023/5/15
 */
@RestController
@RequestMapping("/webSocket")
public class TestController {

    @GetMapping("/test")
    public void test(@RequestParam String merchantId){
        WebSocketServer.sendMessage(merchantId,"有新订单啦");
    }

    @GetMapping("/test2")
    public String test2(@RequestParam String merchantId){
        ResultObject<Integer> success = ResultObject.success(1);
        String jsonString = JSONObject.toJSONString(success);
        WebSocketServer.sendMessage(merchantId,jsonString);
        return jsonString;
    }
}
